home *** CD-ROM | disk | FTP | other *** search
- /*
- File: OSLDspse.c (Orignal name: OSLDispose.c)
-
- Contains:
-
- Owned by: Nick Pilch
-
- Copyright: © 1992 - 1995 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <4> 6/23/95 NP 125932: Call system handlers if app
- handlers fail.
- <3> 1/12/95 jpa Don't use obsolete Toolbox names [1211211]
- <2> 8/19/94 NP 1181622: Ownership fix.
- <7> 5/2/94 eeh bug #1160654: various PPC native changes
- <6> 10/18/93 NP Added DisposeTokenProc callback support for
- OpenDoc.
- <5> 8/16/93 NP Adjusted for latest OSL proposal.
- <4> 7/29/93 NP Added missing return value for
- OLSDisposeToken.
- <3> 7/28/93 NP Mods for new token type, OSLToken.
- <2> 7/21/93 NP Fixed #includes.
- <1> 7/21/93 NP first checked in
-
- To Do:
- In Progress:
- */
-
- #ifndef __MIXEDMODE__
- #include <MixedMode.h>
- #endif
-
- #ifndef _OSLPRIV_
- #include "OSLPriv.h"
- #endif
-
- #pragma segment AEObjSuppt
-
- // ———————————————————————— InternalDisposeToken ————————————————————————
-
- // disposes of OSLTokens without calling app's dispose token routine
-
- pascal OSErr
- InternalDisposeToken( OSLToken* token )
- {
- return AEDisposeDesc(token);
- }
-
- // ———————————————————————— DisposeCompEvnt ————————————————————————
-
- // disposes of CompEvnt Handles
-
- static void
- DisposeCompEvnt( CompareEvent c )
- {
- if ( c != NULL )
- {
- IgnoreOSErr( AEDisposeDesc( &(*c)->theCompEvtInput )) ;
- IgnoreOSErr( AEDisposeDesc( &(*c)->eventWParams ) ) ;
- DisposeHandle((Handle)c ) ;
- }
- } // DisposeCompEvnt
-
- /*———————————————————————— DisposeCompare ————————————————————————*/
-
- /*disposes of comparison Handles*/
- void
- DisposeCompare( Comparison c )
- {
- if ( c != NULL )
- {
- IgnoreOSErr( AEDisposeDesc( &(*c)->theCompInput )) ;
- DisposeObj( (*c)->obj1 ) ;
- DisposeObj( (*c)->obj2 );
- DisposeHandle((Handle)c ) ;
- }
- } // DisposeCompare
-
- /*———————————————————————— DisposeLogical ————————————————————————*/
-
- void
- DisposeLogical( Logical l )
- {
- if ( l != NULL )
- {
- IgnoreOSErr( AEDisposeDesc( &(*l)->theLogicalInput ) ) ;
- DisposeTerm( (*l)->firstTerm ) ;
- DisposeHandle( (Handle)l ) ;
- }
- }
-
-
- /*———————————————————————— DisposeTerm ————————————————————————*/
-
- void
- DisposeTerm( Term t )
- /*disposes of test term Handles*/
-
- {
- if ( t != NULL )
- {
- DisposeTerm( (*t)->next ) ;
- IgnoreOSErr( AEDisposeDesc( &(*t)->theTermInput ) ) ;
-
- switch ( (*t)->ttype )
- {
- case kCompare :
- DisposeCompare( (Comparison)(*t)->u.compar ) ;
- break ;
- case kCompareEvt :
- DisposeCompEvnt( (CompareEvent)(*t)->u.cEvt ) ;
- break ;
- case kLogical :
- DisposeLogical( (Logical)(*t)->u.log ) ;
- break ;
- }
-
- DisposeHandle( (Handle)t ) ;
- }
- } /*DisposeTerm*/
-
-
- /*———————————————————————— DisposeWhose ————————————————————————*/
-
- void
- DisposeWhose( Whose w )
- /*disposes of Whose Handles*/
- {
- if ( w != NULL )
- {
- DisposeTerm( (*w)->theTerm ) ;
- IgnoreOSErr( AEDisposeDesc( &(*w)->theWhoseInput )) ;
- DisposeHandle( (Handle)w ) ;
- /* don't dispose of whose value, it is an end product! */
- }
- } /*DisposeWhose*/
-
-
- /*———————————————————————— DisposeObj ————————————————————————*/
-
- void
- DisposeObj( Object o )
- /*disposes of object records in comparison Handles*/
-
- {
- if ( o != NULL )
- {
- HLock( (Handle) o ) ; /* AEDisposeDesc may write back, so don't let it move */
- // WITH o** DO /* ...and as long as we're locking... */
- {
- ObjRecordPtr op = *o ;
- DisposeObj( op->objContainer );
- DisposeWhose( (Whose)op->objTheWhose );
- IgnoreOSErr( AEDisposeDesc( &op->objSelectionData )) ;
- IgnoreOSErr( AEDisposeDesc( &op->theObjInput )) ;
-
- /* objValue is sometimes a token, sometimes not. eg in the case where
- we are comparing a word with text obj2 has the text as its value. */
-
- if ( op->objRedo )
- {
- if ( !op->valIsExmn )
- IgnoreOSErr( iAEDisposeToken( &op->objValue ) ) ;
- }
- else if ( ! (op->objClass == typeToken) ) /* test added 4/4 as part of ccnt conversion */
- // IgnoreOSErr( AEDisposeDesc( &op->objValue ) ) ;
- IgnoreOSErr( OSLDisposeToken( &op->objValue ) ) ;
-
- }
- DisposeHandle( (Handle) o ) ;
- }
- } /*DisposeObj*/
-
-
- ////////////////////////////////////////////////////////////////////////////////
- // iAEDisposeToken
- // if the app calls disposeToken and there is no such proc, it should return
- // an error -- NoSuchProcErr toka. But if I call it and there is none,
- // AEDisposeDesc should be called instead. Best solution for now is not
- // to treat the absence of a proc as an error; just default to disposeDesc().
- ////////////////////////////////////////////////////////////////////////////////
-
- static OSErr
- TryOneProc( GlobalRecHandle aGlobalRef, OSLToken *theDesc )
- {
- OSErr err = errAENotASpecialFunction ; // with "|" below, fixes LLD-UPG-8 }
- if ( aGlobalRef != NULL )
- {
- OSLDisposeTokenUPP aProcPtr = (*aGlobalRef)->diposeTokenProcPtr ;
- if ( aProcPtr != NULL )
- err = CallOSLDisposeTokenProc(aProcPtr, theDesc);
- }
- return err ;
- }
-
-
- pascal OSErr
- iAEDisposeToken( OSLToken *theDesc ) // Directly from Ed's stuff; not a word changed }
- {
- OSErr err ;
-
- if ( theDesc->descriptorType != typeNull )
- {
- err = NewCallDisposeToken(theDesc);
- // err = TryOneProc( GetGlobalRef(), theDesc ) ;
- if ((err == errAEEventNotHandled)
- || (err == errAENotASpecialFunction) )
- err = TryOneProc( GetSysGlobal(), theDesc ) ; // not there? then try the system-wide one
- if (( err == errAEEventNotHandled)
- || (err == errAENotASpecialFunction) )
- err = AEDisposeDesc( theDesc ) ; // <eeh> here is err where i=166 from command-2
- }
- else
- err = noErr ;
-
- return err ;
- } // iAEDisposeToken
-
-